package org.example.work.pojo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import jakarta.validation.groups.Default;
import lombok.Getter;
import lombok.Setter;
import org.example.work.anno.State;
import org.hibernate.validator.constraints.URL;

import java.time.LocalDateTime;
/**
 * @author 张诗琦
 * @since 2024/12/15 11.34
 * @version 1.0
 */
@Setter
@Getter
public class Subject {
    /**
     *  新增时必须有ID
     * -- GETTER --
     * return the id
     */
    @NotNull(groups = {Update.class})
    @ExcelProperty(value = "id")
    private Integer id;

    /**
     * 标题不能为空，需要满足正则表达式 ^\\S{1,10}$，即1-10个非空白字符
     */
    @NotEmpty
    @Pattern(regexp ="^\\S{1,10}$")
    @ExcelProperty(value = "题目")
    private String title;

    /**
     * 限制文章内容的长度为1000个字符以内
     */
    @NotEmpty
    @Size(max = 1000, message = "文章内容不能超过1000字")
    @ColumnWidth(50)
    @ExcelProperty(value = "内容")
    private String content;

    /**
     * 新增时必须有ID
     * 标题不能为空
     */
    @NotNull(groups = {Update.class})
    @URL
    @ColumnWidth(50)
    @ExcelProperty(value = "图片")
    private String coverImg;
    /**
     * 发布状态 已发布|草稿
     */
    @State
    @ExcelProperty(value = "提交状态")
    private String state;
    /**
     * 文章分类id
     * 创建人ID
     * 创建时间
     * 更新时间
     * 文章等级
     * 文章分类id
     * 文章内容
     * 文章封面图
     * 文章状态
     * 文章分类id
     */
    @NotNull

    @ExcelProperty(value = "课程属性")
    private Integer categoryId;

    @ExcelProperty(value = "姓名")
    private Integer createUser;

    @ColumnWidth(50)
    @ExcelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ColumnWidth(50)
    @ExcelProperty(value = "更新时间")
    private LocalDateTime updateTime;
    @ExcelProperty(value = "成绩")
    private String grade;
    public interface Add extends Default {}
    public interface Update extends Default {}

    public void setCreateDateTime(LocalDateTime now) {
        this.createTime = now;
    }
    public void setUpdateDateTime(LocalDateTime now) {
        this.updateTime = now;
    }

}
